/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', 'Microsoft YaHei', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

/* 容器布局 */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    background-color: #fff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    margin-top: 20px;
}

/* 标题样式 */
h1 {
    text-align: center;
    margin-bottom: 20px;
    color: #2c3e50;
    font-size: 28px;
}

/* 计算器样式 */
.calculator {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* 显示区域样式 */
.display-container {
    background-color: #2c3e50;
    color: #fff;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 20px;
}

.display-history {
    min-height: 20px;
    font-size: 14px;
    color: #bdc3c7;
    text-align: right;
    margin-bottom: 5px;
}

.display {
    font-size: 36px;
    font-weight: bold;
    text-align: right;
    overflow-x: auto;
    white-space: nowrap;
}

/* 按钮网格样式 */
.buttons-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

/* 按钮基础样式 */
.button {
    padding: 20px;
    font-size: 20px;
    font-weight: bold;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.1s ease;
}

.button:hover {
    filter: brightness(1.1);
}

.button:active {
    transform: scale(0.98);
}

/* 数字按钮样式 */
.button.number {
    background-color: #e0e0e0;
    color: #2c3e50;
}

.button.number:hover {
    background-color: #d0d0d0;
}

/* 零按钮样式 */
.button.zero {
    grid-column: span 2;
}

/* 运算符按钮样式 */
.button.operator {
    background-color: #f39c12;
    color: #fff;
}

.button.operator:hover {
    background-color: #e67e22;
}

/* 功能按钮样式 */
.button.function {
    background-color: #95a5a6;
    color: #fff;
}

.button.function:hover {
    background-color: #7f8c8d;
}

/* 等号按钮样式 */
.button.equals {
    background-color: #3498db;
    color: #fff;
}

.button.equals:hover {
    background-color: #2980b9;
}

/* 历史记录区域样式 */
.history-section {
    margin-top: 30px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.history-header h3 {
    color: #2c3e50;
    font-size: 20px;
}

.clear-history-btn {
    padding: 8px 16px;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s ease;
}

.clear-history-btn:hover {
    background-color: #c0392b;
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px;
    background-color: #f8f9fa;
}

.history-item {
    padding: 8px;
    margin-bottom: 8px;
    background-color: #fff;
    border-radius: 4px;
    border-left: 4px solid #3498db;
}

.no-history {
    text-align: center;
    color: #666;
    padding: 20px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        padding: 15px;
    }
    
    .button {
        padding: 15px;
        font-size: 18px;
    }
    
    .display {
        font-size: 28px;
    }
    
    .history-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .clear-history-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .container {
        margin: 5px;
        padding: 10px;
    }
    
    .calculator {
        padding: 15px;
    }
    
    .buttons-grid {
        gap: 8px;
    }
    
    .button {
        padding: 12px;
        font-size: 16px;
    }
}